package com.relytosoft.mizar.media.analyze.services.controller.behavior;

import com.relytosoft.dubhe.common.core.object.ResponseResult;
import com.relytosoft.mizar.media.analyze.api.pojo.dto.AyLaneWithRegionParentDto;
import com.relytosoft.mizar.media.analyze.api.pojo.vo.AyLaneWithRegionVo;
import com.relytosoft.mizar.media.analyze.services.service.behavior.AyLaneWithRegionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author lj
 * @date 2022/6/13 15:13
 */
@Api(tags = "行为分析任务")
@RestController
@RequestMapping("/analyze/behavior")
public class AyLaneWithRegionController {

    @Resource
    private AyLaneWithRegionService ayLaneWithRegionService;

    /**
     * 添加/修改/删除/设备图像信息
     */
    @ApiOperation("设备画图信息")
    @PostMapping("/update")
    public ResponseResult<Void> add(@RequestBody AyLaneWithRegionParentDto ayLaneWithRegionParentDto) {
        //调用service层的方法
        boolean isSuccess = ayLaneWithRegionService.addAyLaneWithRegion(ayLaneWithRegionParentDto);
        if (isSuccess) {
            return ResponseResult.ok();
        }
        return ResponseResult.fail();
    }

    @ApiOperation("绘制检测区域回显")
    @GetMapping("/getByDeviceId/{deviceId}")
    public ResponseResult<List<AyLaneWithRegionVo>> getByDeviceId(@PathVariable String deviceId) {
        return ResponseResult.ok(ayLaneWithRegionService.getByDeviceId(deviceId));
    }
}
